package com.cs.service.user.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cs.mapper.UserMapper;
import com.cs.pojo.User;
import com.cs.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImplMP extends ServiceImpl<UserMapper, User> implements IUserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public IPage<User> getPage(int currentPage, int pageSize) {
        IPage<User> page=new Page<User>(currentPage,pageSize);
        userMapper.selectPage(page,null);
        return page;
    }
    @Override
    public IPage<User> getPageByPhone(int currentPage, int pageSize, String phone) {
        LambdaQueryWrapper<User> lambdaQueryWrapper=new LambdaQueryWrapper<>();
        lambdaQueryWrapper.like(User::getPhone,phone);
        IPage<User> page=new Page<>(currentPage,pageSize);
        userMapper.selectPage(page,lambdaQueryWrapper);
        return page;
    }
}
